﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace OrganizeYourSearch
{
    /// <summary>
    /// The word or collection of words used for tagging (what gets displayed in tagcloud)
    /// </summary>
    public class Tag : INotifyPropertyChanged
    {
        

        /// <summary>
        /// Primary Key
        /// </summary>
        public long TagId { get; set; }

        /// <summary>
        /// Tag Word
        /// </summary>
        public string TagName { get; set; }

        /// <summary>
        /// No of occurances of the current TagWord
        /// </summary>
        public long CurrentFreq { get; set; }

        /// <summary>
        /// Relative Size of the tag word in tag cloud
        /// </summary>
        public int SizeFactor { get; set; }

        /// <summary>
        /// Default Constructor
        /// </summary>
        public Tag()
        {

        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="v_tagId">Primary Key (Identifier)</param>
        /// <param name="curFreq"> No of occurances of the currently tagged tag word</param>
        /// <param name="v_tagName">Word (string) used as a tag</param>
        /// <param name="maxFreq">No of occurances of the most tagged TagWord</param>
        /// <param name="minFreq">No of occurances of the least tagged TagWord</param>
        public Tag(long v_tagId, long curFreq, string v_tagName, long maxFreq, long minFreq)
        {
            TagId = v_tagId;
            TagName = v_tagName;
            CurrentFreq = curFreq;
            SizeFactor = Helpers.TagHelper.CalculateSizeFactor(curFreq, maxFreq, minFreq);
        }



        #region INotifyPropertyChanged Members
        // Property Changed Event
        public event PropertyChangedEventHandler PropertyChanged;
        // Function to explicitly raise the event
        public void OnPropertyChanged(PropertyChangedEventArgs e)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, e);
            }
        }

        #endregion
    }
}
